package com.hovhanna.monopoly.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;

import com.hovhanna.monopoly.model.deeds.Deed;
import com.hovhanna.monopoly.model.slots.OwnableSlot;
import com.hovhanna.monopoly.model.slots.Slot;

public class Board extends Model<Board.BoardEvent> {
    private final Game game;
    private List<Slot> slots = new ArrayList<Slot>();
    private Map<Player, Collection<OwnableSlot>> playersOwnedSlots = new HashMap<Player, Collection<OwnableSlot>>();
    private Cards chanceCards;// = new Cards();
    private Cards chestCards;// = new Cards();
    
    public Board(Game game) {
        this.game = game;
    }
    
    public int rollDice() {
        return game.rollDiceNeeded();
    }

    public <T extends Deed> int getPlayerOwnedDeedsCount(Player owner, Class<T> deed) {
        int count = 0;
        Collection<OwnableSlot> collection = playersOwnedSlots.get(owner);
        if (collection != null) {
            for (OwnableSlot slot : collection) {
                if (slot.getDeed().getClass().equals(deed)) {
                    ++count;
                }
            }
        }
        return count;
    }
    
    public static enum BoardEvent {
        ROLL_DICE;
    }
}
